package com.ctl.controller;

import com.ctl.config.LoginToken;
import com.ctl.dto.UserDTO;
import com.ctl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
public class UserController {
    @Autowired
    private UserService service;
    @Autowired
    private LoginToken loginToken;
    @GetMapping
    public UserDTO pageAll(@RequestParam(defaultValue = "1") Integer page,
                           @RequestParam(defaultValue = "1") Integer per_page,
                           Integer id, String name, String phone,String token){
//        if (token==null){
//            throw new RuntimeException("用户尚未登录，请先登录!");
//        }
        loginToken.runExeption(token);
        return service.pageLike(page,per_page,id,name,phone);

    }



}
